<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>抽奖活动管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/lottery/activity/">抽奖活动列表</a></li>
		<shiro:hasPermission name="lottery:activity:edit"><li><a href="${ctx}/lottery/activity/form">抽奖活动添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="activity" action="${ctx}/lottery/activity/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>发布用户：</label>
				<form:select path="openid" class="input-medium">
					<form:option value="" label=""/>
					<c:forEach var="manager" items="${mangerList}">
						<form:option value="${manager.id}" label="${manager.nickname}"/>
					</c:forEach>
				</form:select>
			</li>
			<li><label>活动名称：</label>
				<form:input path="name" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>
			<li><label>开始时间：</label>
				<input name="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${activity.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</li>
			<li><label>结束时间：</label>
				<input name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${activity.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</li>
			<li><label>状态编码：</label>
				<form:select path="statusId" class="input-medium">
					<form:option value="" label=""/>
					<c:forEach var="status" items="${statusList}">
						<form:option value="${status.id}" label="${status.description}"/>
					</c:forEach>
				</form:select>
			</li>
			<li><label>形式编码：</label>
				<form:select path="formId" class="input-medium">
					<form:option value="" label=""/>
					<c:forEach var="form" items="${formList}">
						<form:option value="${form.id}" label="${form.description}"/>
					</c:forEach>
				</form:select>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
		<tr>
			<th>活动编号</th>
			<th>发布用户</th>
			<th>活动名称</th>
			<th>活动图片url</th>
			<th>活动奖品</th>
			<th>详情介绍</th>
			<th>开始时间</th>
			<th>结束时间</th>
			<th>最少参与人数</th>
			<th>状态编码</th>
			<th>状态解释</th>
			<th>开奖形式编码</th>
			<shiro:hasPermission name="lottery:activity:edit">
				<th>操作</th>
			</shiro:hasPermission>
		</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="activity">
			<tr>
				<td><a href="${ctx}/lottery/activity/form?id=${activity.id}">
						${activity.id}
				</a></td>
				<td>
						${wechatUserMap[activity.openid]}
				</td>
				<td>
						${activity.name}
				</td>
				<td>
					<img src="${activity.image}" width="75" height="75">
				</td>
				<td>
					<table>
						<c:forEach items="${prizeMap[activity.id]}" var="prize">
							<tr><td>${prize.description} ${prize.name} 数量[${prize.quantity}]</td></tr>
						</c:forEach>
					</table>
				</td>
				<td>
						${fns:unescapeHtml(activity.detail)}
				</td>
				<td>
					<fmt:formatDate value="${activity.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					<fmt:formatDate value="${activity.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
						${activity.minNum}
				</td>
				<td>
						${statusMap[activity.statusId]}
				</td>
				<td>
						${activity.explanation}
				</td>
				<td>
						${formMap[activity.formId]}
				</td>
				<shiro:hasPermission name="lottery:activity:edit">
					<td>
						<a href="${ctx}/lottery/activity/form?id=${activity.id}">修改</a>
						<a href="${ctx}/lottery/activity/delete?id=${activity.id}"
						   onclick="return confirmx('确认要删除该抽奖活动吗？', this.href)">删除</a>
					</td>
				</shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>